//引入
import { JSEncrypt } from "jsencrypt";
import { KEY } from "./constant";

export const passwordEncryption = (param) => {
  // 后台给的公钥
  let publicKey = KEY;
  let encryptor = new JSEncrypt(); // 新建JSEncrypt对象
  encryptor.setPublicKey(publicKey); // 设置公钥
  // 对密码进行加密
  return encryptor.encrypt(param);
};

// 解密
export const decrypt = (msg) => {
  const privateKey = "";
  let decrypt = new JSEncrypt();
  decrypt.setPrivateKey(privateKey);
  return decrypt.decrypt(msg);
};
